﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Threading;
using System.IO;

namespace TiecCuoi
{
     public partial class Form1
     {
         //Bien de xu ly giao dien
         int _Index, _ChildIndex;
         //ket noi SQL
         private SqlConnection _CNN;
         //khoi tao cac bien xu ly
         private void KhoiTao()
         {
             _Index = 0;
             _ChildIndex = 0;
         }
         //KetNoiQSL
         void KetNoiSQL()
         {
             _CNN = new SqlConnection();
             try
             {
                 // Open the connection
                 string path = System.IO.Directory.GetCurrentDirectory();
                 _CNN.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + path +
                     @"\DataBase\QUANLYTIECCUOI.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
                // _CNN.ConnectionString = @"Data Source=LANGQUANG-PC\SQLEXPRESS;Initial Catalog=QUANLYTIECCUOI;Integrated Security=True";
                 _CNN.Open();
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Lỗi kết nối CSDL", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 Application.Exit();
             }
         }
     }




}
